import axios from 'axios'

const EXPENSE_BASE_REST_API_URL = "http://localhost:8090/api/v1/expenses";

class ExpenseService {
    getAllExpenses(params = {}) {
        return axios.get(EXPENSE_BASE_REST_API_URL, {
            params: params
        });
    }

    addExpense(expense) {
        return axios.post(EXPENSE_BASE_REST_API_URL, expense)
    }
    
    deleteExpense(expenseId) {
        return axios.delete(EXPENSE_BASE_REST_API_URL + "/" + expenseId);
    }

updateExpense(expenseId, expense) {
  return axios.put(`${EXPENSE_BASE_REST_API_URL}/${expenseId}`, expense);
}



exportExpenses(params = {}) {
    return axios.get(EXPENSE_BASE_REST_API_URL + "/export", {
        params: params,
        responseType: 'blob' 
    });
}
importExpenses(file) {
        const formData = new FormData();
        formData.append('file', file);
        
        return axios.post(EXPENSE_BASE_REST_API_URL + '/import', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    }
    
   









}

export default new ExpenseService();